<html>
<head><meta charset="utf-8"><title>testing libc changes via -Z build-std · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html">testing libc changes via -Z build-std</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218886939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218886939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonah Petri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218886939">(Dec 04 2020 at 20:25)</a>:</h4>
<p>Hello! I'm working on a change to libc to fix some broken platforms, and there is a request to look into adding CI to the libc project for the platforms I'm fixing, so they don't bitrot.  As it happens, there's no official builds for these platforms (e.g. mipsel-unknown-linux-uclibc) so the suggestion was made that I try to use -Z build-std to build the necessary dependencies, rather than building a full rust toolchain in CI, which was not considered a good use of resources.  However, I'm running into the problem that -Z build-std does not seem to be able to consider patches, so it always tries to build the current toolchain's idea of libc, which of course fails.  It's a bit of a chicken-and-egg problem.</p>
<p>In working on this, the suggestion was made that maybe libc doesn't need all of build-std, but rather maybe just needs core.  However, I am well out of my element here and would appreciate some help understanding how to get what I need.  Is it possible to use build-std in this way?  Or am I barking up the wrong tree?</p>
<p>For reference, the PR in question is here: <a href="https://github.com/rust-lang/libc/pull/1975">https://github.com/rust-lang/libc/pull/1975</a></p>
<p>Many thanks for any assistance!</p>



<a name="218887404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218887404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218887404">(Dec 04 2020 at 20:29)</a>:</h4>
<p>(I suggested both -Z build-std and only building core, so if this is the wrong approach you can blame me)</p>



<a name="218888013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218888013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218888013">(Dec 04 2020 at 20:34)</a>:</h4>
<p><span class="user-mention" data-user-id="369589">@Jonah Petri</span> Have you tried <code>-Zbuild-std=core</code>?  That should restrict it to core only.  I think you also need <code>--no-default-features</code>.</p>



<a name="218888588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218888588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonah Petri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218888588">(Dec 04 2020 at 20:41)</a>:</h4>
<p>That got me farther!  libc builds, but libc-test doesn't.  Cargo panics like so:</p>
<div class="codehilite"><pre><span></span><code>skrap@pop-os:/tmp/libc/libc-test$ RUST_BACKTRACE=1 cargo +nightly build --target mipsel-unknown-linux-uclibc -Z build-std=core --no-default-features
    Updating crates.io index
thread &#39;main&#39; panicked at &#39;no entry found for key&#39;, src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs:324:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/core/src/option.rs:1260:5
   3: cargo::core::compiler::context::compilation_files::CompilationFiles::outputs
   4: cargo::core::compiler::context::Context::compile
   5: cargo::ops::cargo_compile::compile_ws
   6: cargo::ops::cargo_compile::compile
   7: cargo::commands::build::exec
   8: cargo::cli::main
   9: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
</code></pre></div>



<a name="218888742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218888742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218888742">(Dec 04 2020 at 20:43)</a>:</h4>
<p>I think that's the first cargo panic I've ever seen</p>



<a name="218892287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218892287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218892287">(Dec 04 2020 at 21:16)</a>:</h4>
<p>You won't be able to build tests with just core.  Also, running <code>cargo build</code> in that directory doesn't do anything since that package is a test-only package.   I can probably fix the panic, though.</p>



<a name="218892525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218892525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonah Petri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218892525">(Dec 04 2020 at 21:19)</a>:</h4>
<p>Yeah, good point, so libc-test is a test-only package, and has requirements beyond core.  Presumably any CI for libc would need libc-test, so I am back to my original chicken-and-egg problem: I can't build -Z build-std against custom libc.  Do I have that right?</p>



<a name="218892849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218892849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218892849">(Dec 04 2020 at 21:22)</a>:</h4>
<p><span class="user-mention" data-user-id="369589">@Jonah Petri</span> I think @johntitor would be ok with just making sure it compiles in a first pass</p>



<a name="218892866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218892866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218892866">(Dec 04 2020 at 21:23)</a>:</h4>
<p>actually I don't think running tests will work anyway because it's cross compiled</p>



<a name="218893021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218893021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonah Petri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218893021">(Dec 04 2020 at 21:24)</a>:</h4>
<p>Yeah I was going to spin up something in qemu to run the tests, but I suppose that can wait until later.</p>



<a name="218893069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218893069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218893069">(Dec 04 2020 at 21:25)</a>:</h4>
<p>that seems a little overkill tbh <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="218893355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/testing%20libc%20changes%20via%20-Z%20build-std/near/218893355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonah Petri <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/testing.20libc.20changes.20via.20-Z.20build-std.html#218893355">(Dec 04 2020 at 21:28)</a>:</h4>
<p>Perhaps, but it was about 3x the work to get the tests to pass compared  to getting it compiling.  Pretty much anything in libc compiles :)  Anyhow, I have a path forward, so thanks <span class="user-mention" data-user-id="232545">@Joshua Nelson</span> and <span class="user-mention" data-user-id="120518">@Eric Huss</span> !</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>